package imgsei.wcj.com.commonbusiness.base.presenter;

import imgsei.wcj.com.commonbusiness.interfaces.callback.IBaseRequestCallBack;
import imgsei.wcj.com.commonbusiness.interfaces.view.IBaseView;

public class BasePresenterImp<V extends IBaseView, T> implements IBaseRequestCallBack<T> {

    private IBaseView iBaseView = null;  //基类视图

    public BasePresenterImp(V iBaseView){
        this.iBaseView = iBaseView;
    }

    @Override
    public void beforeRequest() {
        if (iBaseView!=null){
            iBaseView.showProgress();
        }

    }

    @Override
    public void requestError(Throwable throwable) {
        if (iBaseView!=null){
            iBaseView.loadDataError(throwable);
            iBaseView.hideProgress();}
    }

    @Override
    public void requestComplete() {
        if (iBaseView!=null){
            iBaseView.hideProgress();}
    }

    @Override
    public void requestSuccess(T callback) {
        if (iBaseView!=null){
            iBaseView.loadDataSuccess(callback);
            iBaseView.hideProgress();}
    }
}
